﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="ProductList.aspx.vb" Inherits="FishTank.ProductList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h1>Aquarium Product List</h1>
       
    <div class="search">
        Search by 
        <asp:DropDownList ID="SearchType" runat="server">
            <asp:ListItem Value="Model">Model</asp:ListItem>
            <asp:ListItem Value="Manufacturer">Manufacturer</asp:ListItem>
        </asp:DropDownList>
        <asp:TextBox ID="SearchBox" runat="server" AutoPostBack="True"></asp:TextBox>
        <asp:Button ID="SearchButton" runat="server" Text="Go" />
        <asp:Button ID="ResetButton" runat="server" Text="Reset" />
    </div>

    <p>
    <asp:GridView ID="ListGrid" runat="server"
        AutoGenerateColumns="False" AllowSorting="True" Width="100%"
        CssClass="gridView">

        <AlternatingRowStyle CssClass="gridAltRowView" />

        <EmptyDataTemplate>
        <p>Your search did not match any products.</p>
        </EmptyDataTemplate>
        
        <Columns>
            <asp:HyperLinkField DataNavigateUrlFields="ID" 
                DataNavigateUrlFormatString="/Pages/ProductDetail.aspx?ID={0}" DataTextField="Model" 
                HeaderText="Model" SortExpression="Model" />
            <asp:HyperLinkField DataNavigateUrlFields="ID" 
                DataNavigateUrlFormatString="/Pages/ProductDetail.aspx?ID={0}" DataTextField="Manufacturer" 
                HeaderText="Manufacturer" SortExpression="Manufacturer" />
            <asp:BoundField DataField="Length" HeaderText="Length (cm)" SortExpression="Length" />
            <asp:BoundField DataField="Height" HeaderText="Height (cm)" SortExpression="Height" />
            <asp:BoundField DataField="Width" HeaderText="Width (cm)" SortExpression="Width" />
            <asp:HyperLinkField DataNavigateUrlFields="MemberUserName" 
                DataNavigateUrlFormatString="/Pages/MemberDetail.aspx?UserName={0}" DataTextField="MemberFullName" 
                HeaderText="Created By" SortExpression="MemberFullName" />
            <asp:BoundField DataField="CreatedDateTime" HeaderText="Created Date" 
                dataformatstring="{0:MMMM d, yyyy}" ItemStyle-CssClass="centered"
                SortExpression="CreatedDateTime" />
            <asp:TemplateField HeaderText="Website" ItemStyle-CssClass="centered">
                <ItemTemplate>  
                    <asp:Panel ID="WebsitePanel" runat="server"
                               Visible='<%# Not String.IsNullOrWhiteSpace(Convert.ToString(Eval("URL"))) %>'>
                        <a href="<%# Eval("URL") %>">
                            <asp:Image ID="WebsiteLinkImage" runat="server"
                                       ImageUrl="~/Images/website.png" AlternateText="Website URL"/>
                        </a>
                    </asp:Panel>
                    
                </ItemTemplate>
                <ItemStyle Width="64" Height="64" />
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    </p>

    <p class="submitButton">
        <asp:Button ID="CreateButton" runat="server" CommandName="Create" Text="Add a product" />
    </p>
</asp:Content>
